﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SolverLibrary.Data_Entities
{
    public class SudokuBoardItem : Item
    {
        private static Dictionary<int, Item> flyWeight = new Dictionary<int, Item>();

        private int value = 0;

        public static Item getSudokuBoardItem(int i)
        {
            if (i < 0 || i > 9)
            {
                throw new ArgumentOutOfRangeException(
                    "Cannot have a sudoku item with value " + i);
            }
            if (!flyWeight.ContainsKey(i))
            {
                flyWeight.Add(i, new SudokuBoardItem(i));
            }
            return flyWeight[i];
        }

        private SudokuBoardItem()
        {
        }

        private SudokuBoardItem(int value)
        {
            this.value = value;
        }

        public int intValue()
        {
            return this.value;
        }

        public override string ToString()
        {
            return value.ToString();
        }
    }
}
